var ProjectView = function(data) {
	//alert(Ext.util.JSON.encode(data));
	//data.AREA_ID=OMS.PROJECTSTATUS[data.AREA_ID];
	//data.AREA_ID='上海';
	var ps = new ProjectSource();
	ps.setCompValueAndDisabled2(data);
	ps.projectIsVs.setValue(true);
	
	var projectCode = null;
	var project_id ='-1';
	
	var projectStatus = new Ext.form.TextField({
		fieldLabel : '项目状态',
		disabled:true,
		width : 150,
		value : OMS.PROJECTSTATUS[data.STATUS]
	});
	
	this.spPanel = new Ext.FormPanel({
		frame : true,
		width : 950,
		labelWidth : 85,
		items : [projectStatus,ps.projectInfo,ps.projectNeed,ps.projectIsVs,ps.projectVsInfo]
	});
	
	
	if(data.STATUS=='24'){
		//alert("未签约原因");
		//未签约原因
		var reasionArea = new Ext.form.TextArea({
			fieldLabel : '原因',
			disabled:true,
			width : 800
		});
		
		var reasion = new Ext.form.FieldSet({
			title : '未签约原因',
			collapsible : true,
			autoHeight : true,
			width : 930,
			items : [reasionArea]
		});
		reasionArea.setValue(data.TPSREMARK);
		this.spPanel.add(reasion);
		
		//未签约原因
	}
	if(data.STATUS=='30'){
		//alert("签约原因");
		
		// 签约信息---begin
		var signInfo = new Ext.form.FieldSet({
			title : '签约信息',
			collapsible : true,
			autoHeight : true,
			width : 930, 
			items : [],
			buttons : [{text:'保存',iconCls: 'icon-accept',scope:this,handler:function(){saveSign(this.spPanel);}},{text:'取消'}]
		});
		var fileUpload = new Ext.form.FileUploadField({
			fieldLabel : '上传附件',
			emptyText: '请选择要上传的文件',
			width : 520,
			disabled:true,
			name : 'fileName',
			buttonText: '',
			buttonCfg: {
	            iconCls: 'icon-compress'
	        }
		});
		
	
		// 签约信息---end
		//reasionArea.setValue(data.TPSREMARK);
		signInfo.add({layout:'column',
						  defaults:{layout:'form',columnWidth:0.3},
						  items:[{items:[{xtype:'datefield',
							  			  fieldLabel : '签约时间',
							  			  name:'signTime',
							  			  value:data.SIGN_DT,disabled:true,
							  			  format : 'Y-m-d',
							  			  width : 150}]},
							  	 {items:[{xtype:'numberfield',
							  		 	  name : 'income',
							  		 	  value:data.REVENUE,disabled:true,
						  			   fieldLabel:'预计收入',
						  			   width:150}]},
						  	     {items:[{xtype:'numberfield',
						  	    	 	  name :'exeCycle',
						  	    	 	  value:data.PERIOD,disabled:true,
						  			   fieldLabel:'实施周期',
						  			   width:150}]}
							  			]});
		signInfo.add({xtype:'textarea',
					  width:600,
					  	name: 'payCondition',
					  	value:data.PAY_CONDITION,disabled:true,
					  fieldLabel:'付款条件'});
		//signInfo.add(fileUpload);
		signInfo.doLayout();
			
		//this.spPanel.add(projectStatus);
		//'SIGN_DT','REVENUE','PERIOD'
		this.spPanel.add(signInfo);
		
		//未签约原因
	}
	var downloadUrl = function(s, m, rec){
		return "<a href='../task/downloadFile.form?fileId="+s+"'>下载</a>";
	};
	//附件列表
	var fileStore = new Ext.data.JsonStore(
			{
				url : '../task/searchTaskUpLoadFile.form?timesnap='+new Date().getTime(),
				baseParams: {exeId: '-1'},
				root : 'result',
				fields: ['ACCESSORY_ID', 'ACCESSORY_NAME', 'UPLOAD_DATE','FILE_SIZE','UPLOAD_NAME','ACCESSORY_DESC','USER_NAME'],
				listeners : {
					scope : this,
					beforeload : function(thiz) {
						thiz.baseParams = { exeId : project_id };
					}
				}
			});
	var fileGrid = new Ext.grid.GridPanel({
		width : 900,
		height : 150,
		store : fileStore,
		columns : [{header:'附件名称',width: 150,dataIndex:'ACCESSORY_NAME'},
		           {header:'上传日期',width: 150,dataIndex:'UPLOAD_DATE'},
		           {header:'文件大小(K)',width: 250,dataIndex:'FILE_SIZE'},
		           {header:'上传人',width: 250,dataIndex:'USER_NAME'},
		           {header: '操作',width: 50, dataIndex: 'ACCESSORY_ID',renderer:downloadUrl}
		           ],
   		bbar:new Ext.PagingToolbar({
   		   pageSize: 5,
            store: fileStore,
            displayInfo: true,
            displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
            emptyMsg: "没有记录..."
           })
	});
	var fileUploadInfo = new Ext.form.FieldSet({
		title : '附件信息',
		collapsible : true,
		autoHeight : true,
		width : 930, 
		items : [fileGrid]
	});
	this.spPanel.add(fileUploadInfo);
	

	
	ProjectView.superclass.constructor.call(this, {
		title: '预览',
        bodyStyle: 'padding: 5px 5px 0',
        autoHeight: true,
        width: 750,
        y: 50,
        resizable: false,
        plain: true,
        modal: true,
        closeAction: 'hide',
        items: [this.spPanel],
		buttons: [{
            text: '关闭',
            scope: this,
            handler: function() {
	        	this.hide();
        	}
        }],
        buttonAlign:'center'
	});
	
	//reasionArea.setValue(data.REMARK2);
	
};
Ext.extend(ProjectView, Ext.Window, {
	initWin:function(data){		
		//var data = grid.store.getAt(index).data; 
		//alert(data.STATUS);
		projectCode = data.PROJECT_ID;
		project_id =data.PROJECT_ID;
		
	}
	
});